[#ftl]
[#import "macrolibs.ftl" as lib]
[#assign myTableName][@lib.fullTableName clazz=clazz/][/#assign]
[#assign myTableAlias][@lib.tableAlias clazz=clazz/][/#assign]
[#if clazz.ownerLevel>0]
    [#assign myOwnerTableName][@lib.ownerTableName level=clazz.ownerLevel/][/#assign]
    [#assign myOwnerTableAlias][@lib.ownerTableAlias level=clazz.ownerLevel/][/#assign]
[/#if]
[#if clazz.scopeClass??]
    [#assign myScopeTableName][@lib.fullTableName clazz=clazz.scopeClass/][/#assign]
    [#assign myScopeTableAlias][@lib.tableAlias clazz=clazz.scopeClass/][/#assign]
[/#if]
[#assign myRefTables={}]
[#assign myRefTableAlias={}]
[#assign myFieldNames={}]
[#assign myFieldValues={}]
[#assign myAttrNames={}]
[#list clazz.dynaAttributes as attr][#if !attr.carrier]
    [#assign fieldName][@lib.fieldName attr=attr/][/#assign]
    [#assign myFieldNames=myFieldNames+{"${attr.id}", fieldName}]
    [#assign fieldValue][@lib.fieldValue attr=attr/][/#assign]
    [#assign myFieldValues=myFieldValues+{"${attr.id}", fieldValue}]
    [#assign attrName][@lib.attributeName attr=attr/][/#assign]
    [#assign myAttrNames=myAttrNames+{"${attr.id}", attrName}]
    [#if attr.type==9]
        [#assign jointAlias][@lib.attributeName attr=attr/]_[@lib.tableAlias clazz=attr.refClass/][/#assign]
        [#assign myRefTableAlias=myRefTableAlias+{"${attr.id}", jointAlias}]
        [#assign jointTable][@lib.fullTableName clazz=attr.refClass/][/#assign]
        [#assign myRefTables=myRefTables+{"${attr.id}", jointTable}]
    [/#if]
    [#if attr.type>9]
        [#assign level=("${(attr.type-9)}"?number)]
        [#assign jointAlias][@lib.attributeName attr=attr/]_[@lib.ownerTableAlias level=level/][/#assign]
        [#assign myRefTableAlias=myRefTableAlias+{"${attr.id}", jointAlias}]
        [#assign jointTable][@lib.ownerTableName level=level/][/#assign]
        [#assign myRefTables=myRefTables+{"${attr.id}", jointTable}]
    [/#if]
[/#if][/#list]
